﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

namespace FPTPages.BetPage
{
    public partial class RegisterPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            //try
            //{
            //    string url = "Data source=(local);database=ProjectDatabase;user id=sa;password=123456";
            //    SqlConnection con = new SqlConnection();
            //    con.ConnectionString = url;
            //    con.Open();
            //    string username = tbUserName.Text.Trim();
            //    string pass = tbPassword.Text.Trim();
            //    string mail = tbEmail.Text.Trim();
            //    int point = 10;
            //    string sql = string.Format("INSERT INTO Account" + "(UserName,Pass,Mail,Point) Values" +
            //                    "('{0}','{1}','{2}','{3}')", username, pass, mail, point);
            //    SqlCommand cm = new SqlCommand(sql, con);
            //    cm.ExecuteNonQuery();
            //    Response.Write("<script>alert('Đăng Kí Thành Công !');</script>");
            //}
            //catch(Exception ex) {
            //    Response.Write(ex.Message);
            //}
            if (tbPassword.Text.Trim() != tbReEnterPass.Text.Trim())
            {
                Response.Write("<script>alert('Mật Khẩu Không Trùng Khớp!');</script>");
                return;
            }
            else
            {
                try
                {
                    LINQDataBaseDataContext db = new LINQDataBaseDataContext();
                    int kq = db.Procedure_InsertNewUser(tbUserName.Text.Trim(), tbPassword.Text.Trim(),
                        tbEmail.Text.Trim());
                    if (kq == 1)
                    {
                        Response.Write("<script>alert('Đăng Kí Thành Công !');</script>");
                    }
                    else
                    {
                        Response.Write("<script>alert('Tài khoản đã có người sử dụng!');</script>");
                    }
                }
                catch (Exception ex)
                {

                    Response.Write(ex.Message);
                }
            }
        }


    }
}